package com.qianfeng.missfood.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.lidroid.xutils.BitmapUtils;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.qianfeng.missfood.R;
import com.qianfeng.missfood.category_bean.Category_Info;

import java.util.List;

/**
 * Created by Administrator on 2015/8/17.
 */
public class Category_ListView_adapter extends AppBaseAdapter<String> {
    private List<String> list;
    private Context context;
    public int selectIndex;//要设置成public,然后在那边更改

    public Category_ListView_adapter(List<String> list, Context context) {
        super(list, context);
        this.list = list;
        this.context = context;
    }


    @Override
    public View getItemView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.category_left_listview_layout, parent, false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }
        holder = (ViewHolder) convertView.getTag();
        holder.textView.setText(list.get(position));
        if (position==selectIndex) {
            convertView.setBackgroundColor(Color.WHITE);
            holder.textView.setTextColor(Color.parseColor("#FFAA31"));
        } else {
            convertView.setBackgroundColor(Color.parseColor("#EEEEEE"));
            holder.textView.setTextColor(Color.parseColor("#575757"));
        }

        return convertView;
    }


    private static class ViewHolder {
        @ViewInject(R.id.category_listview_item)
        private TextView textView;

        public ViewHolder(View convertview) {
            ViewUtils.inject(this, convertview);
        }
    }
}
